package com.gscitysfy.cus.drain.modules.pipe.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gscitysfy.cloudfrmwk.assistant.domain.Result;
import com.gscitysfy.cus.drain.annotations.DictTranslation;
import com.gscitysfy.cus.drain.annotations.FieldParam;
import com.gscitysfy.cus.drain.constants.DicConstant;
import com.gscitysfy.cus.drain.modules.pipe.entity.DrainPipeHiddenDangerRequisition;
import com.gscitysfy.cus.drain.modules.pipe.service.IDrainPipeHiddenDangerRequisitionService;
import com.gscitysfy.cus.drain.modules.pipe.vo.HiddenDangerRequisitionQueryVo;
import com.gscitysfy.cus.drain.modules.pipe.vo.HiddenDangerRequisitionVo;
import groovy.lang.Lazy;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 隐患通知单 前端控制器
 * </p>
 *
 * @author Axi
 * @since 2022-11-16 12:06:33
 */
@RestController
@RequestMapping("/pipe/requisition")
@Tag(name = "管网隐患管理 -> 隐患通知单")
public class DrainPipeHiddenDangerRequisitionController {
    @Resource
    @Lazy
    IDrainPipeHiddenDangerRequisitionService requisitionService;


    @Operation(summary = "查询通知单列表", description = "查询通知单列表接口")
    @PostMapping("/pageList")
    @DictTranslation({
            @FieldParam(dictType = DicConstant.HIDDEN_DANGER_SOURCE, targetField = "hiddenDangerSource"),
            @FieldParam(dictType = DicConstant.HIDDEN_DANGER_CATEGORY, targetField = "hiddenDangerCategory")
    })
    public Result<IPage<DrainPipeHiddenDangerRequisition>> getPageList(@RequestBody HiddenDangerRequisitionQueryVo queryVo) {
        return Result.content(requisitionService.getPageList(queryVo));
    }

    @Operation(summary = "修改通知单", description = "修改通知单接口")
    @PutMapping(value = "/update")
    public Result<Boolean> update(@RequestBody HiddenDangerRequisitionVo requisitionVo) {
        return requisitionService.update(requisitionVo) ? Result.success() : Result.failure();
    }

    @Operation(summary = "推送通知单", description = "推送通知单接口")
    @PutMapping(value = "/push")
    public Result<Boolean> push(@RequestBody HiddenDangerRequisitionVo requisitionVo) {
        return requisitionService.push(requisitionVo) ? Result.success() : Result.failure();
    }

    @Operation(summary = "获取通知单详情", description = "获取通知单详情接口")
    @GetMapping("/detail")
    @DictTranslation({
            @FieldParam(dictType = DicConstant.HIDDEN_DANGER_SOURCE, targetField = "hiddenDangerSource"),
            @FieldParam(dictType = DicConstant.HIDDEN_DANGER_CATEGORY, targetField = "hiddenDangerCategory"),
            @FieldParam(dictType = DicConstant.HIDDEN_DANGER_LEVEL, targetField = "hiddenDangerLevel")
    })
    public Result<HiddenDangerRequisitionVo> getDetailById(Long id) {
        return Result.content(requisitionService.detailById(id));
    }

}
